class Solution {
public:
    vector<int> dailyTemperatures(vector<int>& temperatures) {
    vector<int>ret(temperatures.size(),0);
    stack<int>a;
    for(int i=0;i<temperatures.size();i++){
        while(!a.empty()&&temperatures[i]>temperatures[a.top()]){
            int t=a.top();
            a.pop();
            ret[t]=i-t;
        }
        a.push(i);
    }
    return ret;
    }
};
